/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bugsandcritters;

import java.awt.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;

/**
 *
 * @author Robert Gibbons
 */
public class Flower extends GameObject{
    
    public static BufferedImage FlowerImage;

    double FlowerLifeTime;
    public static long MaxFlowerLifeTime = 50;
    double Size = 0;
    
    
    
    @Override
    public void Create()
    {
        FlowerLifeTime = MaxFlowerLifeTime;  
        
        super.Create();
    }
    
    @Override
    public void Update()
    {
        System.out.println("Flower Update");
        
        FlowerLifeTime -= DeltaTime/1000000000.0;
        if(FlowerLifeTime<0)
        {
            Size -= DeltaTime/2000000000.0;
            if(Size<0)
                Destroy();
        }
        else
        {
            Size += DeltaTime/4000000000.0;
            if(Size>1)
                Size=1;
        }
        
        super.Update();
    }
    
    @Override
    public void Draw(Graphics g)
    {
        if(FlowerImage == null)
        {
            try
            {
                FlowerImage = ImageIO.read(new File("FlowerImage.png"));
            }
            catch(Exception e){}
        }
        else
        {
            BufferedImage image = FlowerImage;
            g.drawImage(image, (int)(X- image.getWidth()/2.0*Size), 
                    (int)(Y- image.getHeight()/2.0*Size),
                    (int)(Size * image.getWidth()),
                    (int)(Size * image.getHeight()),
                    null);
        }
    }
}
